﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebSite.Core;

namespace WebSite.UserControl
{
    public partial class UserLoginPanel : BaseUserControl
    {
        public Maticsoft.Model.CarrefourCover.Baby currentBabyInfo = null;

        protected void Page_Load( object sender, EventArgs e )
        {
            this.PreRender += new EventHandler( UserLoginPanel_PreRender );
        }

        void UserLoginPanel_PreRender( object sender, EventArgs e )
        {
            this.panelLogin.Visible = Project_Session.CurrentUser == null;
            this.panelLogined.Visible = !this.panelLogin.Visible;
            currentBabyInfo = Project_Session.CurrentUserBaby;

            if (this.panelLogined.Visible)
            {
                // TODO: load baby info
            }
        }

        protected void btlogin_Click( object sender, EventArgs e )
        {
            LoginHelper.SetCurrentUser( tbUserName.Value.Trim(), tbPassword.Value.Trim(), false );
        }

        public string SayHello()
        {
            DateTime now = DateTime.Now;
            if (now.Hour >= 18 || now.Hour < 6)
            {
                return "晚上好!";
            }
            else if (now.Hour >= 6 && now.Hour < 12)
            {
                return "上午好!";
            }
            else
            {
                return "下午好!";
            }
        }

    }
}